import javax.swing.text.html.parser.Entity;
import java.util.HashMap;
import java.util.Map;

public class Main
{
    public static void main(String[] args)
    {

        String context = "  If not now, when? if not me, who? \n\nkshfkjd";
        System.out.println(context);
        context = context.replaceAll("\\?|,|\\.|\\n|\\r", " ").replaceAll("\\s+"," ").trim();
        System.out.println(context);

        String[] array = context.split(" ");

        Map<String, Integer> map = new HashMap<>();

        for(String str : array)
        {
            if(str == null || str.length() == 0)
            {
                continue;
            }
            if(str.charAt(0) >= 'A' && str.charAt(0) <= 'Z')
            {
               str = str.toLowerCase();
            }
            if(map.containsKey(str))
            {
                int count = map.get(str) + 1;
                map.put(str, count);
            }
            else
            {
                map.put(str, 1);
            }
        }
        map.forEach((k,v) -> {
            System.out.println(k + " " + v);
        });
    }
}
